package com.zr.serviceimpl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zr.dao.SearchQuestionsDao;
import com.zr.dao.ShowRolesDao;
import com.zr.model.Cquestion;
import com.zr.model.Crole;
import com.zr.service.ShowRolesService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Service("showRolesService")
public class ShowRolesServiceImpl implements ShowRolesService{

	@Resource ShowRolesDao<Crole> showRolesDao;
	
	@Override
	public JSONArray getAllRoles() {
		JSONArray js = new JSONArray();
		List<Crole> rs = new ArrayList<Crole>();
		rs = showRolesDao.getAllRoles();
		for (Crole r : rs) {
			JSONObject j = new JSONObject();
			j.put("rid", r.getRid());
			j.put("rname", r.getRname());
			js.add(j);
		}
		return js;
	}

}
